package com.yenlien.traceyun.usercenter.bean;

import com.yenlien.traceyun.usercenter.entity.Department;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-11-24
 * @description:
 **/
public class DepartmentTree {

    private String name;

    private String id;

    private String parentId;

    private List<DepartmentTree> children;

    public static DepartmentTree create(Department department) {
        DepartmentTree tree = new DepartmentTree();
        tree.setId(department.getId());
        tree.setName(department.getName());
        tree.setParentId(department.getParentId());
        return tree;
    }

    public static List<Department> create(List<Department> departments) {
        List<DepartmentTree> departmentTrees = new ArrayList<>();
        if (departments != null && departments.size() > 0) {
            for (Department department : departments) {
                departmentTrees.add(create(department));
            }
        }
        return departments;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<DepartmentTree> getChildren() {
        return children;
    }

    public void setChildren(List<DepartmentTree> children) {
        this.children = children;
    }
}
